//#define __DEBUG__
// by Xeno
#define THIS_FILE "fn_sidemissionresolved.sqf"
#include "x_setup.sqf"

if (isNil QGVAR(HC_CLIENT_OBJ)) then {
	execFSM "fsms\XClearSidemission.fsm";
} else {
	[QGVAR(smclear), GVAR(HC_CLIENT_OBJ)] call FUNC(NetCallEventSTO);
};
if (X_SPE) then {
	deleteMarkerLocal (format ["XMISSIONM%1", __XJIPGetVar(GVAR(cur_sm_idx)) + 1]);
	if (GVAR(x_sm_type) == "convoy" || {GVAR(x_sm_type) == "deliver"}) then {deleteMarkerLocal (format ["XMISSIONM2%1", __XJIPGetVar(GVAR(cur_sm_idx)) + 1])};
};
[QGVAR(cur_sm_idx),-1] call FUNC(NetSetJIP);
__TRACE_2("","d_sm_winner","d_current_sm_bonus_vec");
if (GVAR(sm_winner) > 0) then {
	[QGVAR(smgetbonus), [GVAR(sm_winner), GVAR(current_sm_bonus_vec)]] call FUNC(NetCallEventCTS);
};
if (GVAR(sm_winner) in [-1,-2,-300,-400,-500,-600,-700,-878,-879,-880,-881,-900,-999]) then {
	[QGVAR(sm_res_client), [GVAR(sm_winner), ""]] call FUNC(NetCallEventToClients);
	#ifndef __TT__
	[QGVAR(kbmsg), [35]] call FUNC(NetCallEventCTS);
	#else
	[QGVAR(kbmsg), [36]] call FUNC(NetCallEventCTS);
	#endif
	if (!X_SPE) then {GVAR(sm_winner) = 0};
};